<template>
  <div>
    <div style="text-align: left;margin: 10px">
      <el-button type="primary" @click="insertBUG">添加BUG</el-button>
    </div>
    <el-table
      :data="tableBug"
      border
      style="width: 100%"
      height="90vh">
      <el-table-column
        fixed
        prop="buggrade"
        header-align="center"
        align="center"
        sortable
        label="状态">
        <template slot-scope="scope">
          <el-tag :type="scope.row.buggrade == '高' ? 'danger' : 'info'">
            <span v-text="scope.row.buggrade == '高' ? '高' : '低'"></span>
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column
        fixed
        prop="bugcreatetime"
        label="发现时间" width="160">
      </el-table-column>
      <el-table-column
        prop="bugcontent"
        width="200"
        label="Bug内容">
      </el-table-column>
      <el-table-column
        prop="bugsolve"
        width="200"
        label="解决方案">
      </el-table-column>
      <el-table-column
        prop="bugsolvetime"
        label="解决时间"
        width="160">
      </el-table-column>
      <el-table-column
        label="操作"
        width="120">
        <template slot-scope="scope">
          <el-button
            type="primary"
            icon="el-icon-edit"
            circle
            size="small"
            @click.native.prevent="openvalue(scope.$index, tableBug)"></el-button>
          <el-button
            type="danger"
            icon="el-icon-delete"
            circle
            size="small"
            @click.native.prevent="deleteRow(scope.$index, tableBug)"></el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  name: "BugView",
  inject: ['reload'],
  data() {
    return{
      visible: false,
      tableBug: []
    }
  },
  created() {
    this.getBUGData()
  },
  methods:{
    deleteRow(index, rows) {
      this.open(index,rows)
    },
    //返回数据
    getBUGData(){
      this.axios.get(this.Global.BASE_URL+'/BugController/getBugContent').then((res)=>{
        if("2000" == res.data.msg){
          this.tableBug = res.data.data
        }
        else this.$CustomMessage_ERROR('BUG','BUG查询错误！');
      }).catch(erroe=>{
        this.$CustomMessage_ERROR('BUG','BUG错误！');
      })
    },
    insertBUG(){
      this.$parent.$parent.$parent.showSetting(0,1)
    },
    reloadBUG(){
      this.reload()
    },
    //表格
    openvalue(index, rows){
      this.$parent.$parent.$parent.showSetting(this.tableBug[index].bugid,1)
    },
    open(index,rows) {
      this.$confirm('此操作将永久删除该BUG, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        let I = this.tableBug[index].bugid
        this.axios.post(this.Global.BASE_URL+'/BugController/deleteBUG',{I:I}).then((res)=>{
          if("2000" == res.data.msg){
            rows.splice(index, 1);
            this.$CustomMessage_OK('BUG','删除完成！')
          }
          else this.$CustomMessage_ERROR('BUG','BUG查询错误！');
        }).catch(erroe=>{
          this.$CustomMessage_ERROR('BUG','BUG错误！');
        })
      }).catch(() => {
      });
    }
  }
}
</script>

<style scoped>

</style>
